//
//  HRMessageGiftCollectionViewCell.m
//  SpeedDating
//
//  Created by ISU1 on 17/2/7.
//  Copyright © 2017年 isu. All rights reserved.
//

#import "HRMessageGiftCollectionViewCell.h"

@interface HRMessageGiftCollectionViewCell ()

@property (nonatomic, strong) UIImageView *borderImageView;

@property (nonatomic, strong) UILabel *charmLabel;

@property (nonatomic, strong) UILabel *nameLabel;

@property (nonatomic, strong) UIImageView *showImageView;
@property (nonatomic, strong) UIImageView *charmImage;

@end

@implementation HRMessageGiftCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        _showImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_showImageView];
        _showImageView.contentMode = UIViewContentModeScaleAspectFit;
        [_showImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(10);
            make.height.width.mas_equalTo(80*SCREEN_WIDTH_RATIO47);
            make.centerX.equalTo(self.contentView);
        }];
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = [UIColor lightGrayColor];
        _nameLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:_nameLabel];
        
        
        _borderImageView = [[UIImageView alloc] init];
        _borderImageView.image = [UIImage imageNamed:@"Message_Border"];
        [self.contentView addSubview:_borderImageView];
       
        
        
        _charmLabel = [[UILabel alloc] init];
        _charmLabel.backgroundColor = [UIColor blackColor];
        _charmLabel.font = FontP(12);
        _charmLabel.textColor = ColorI(0xfdd815);
        [self.contentView addSubview:_charmLabel];
        
        _charmImage = [[UIImageView alloc] init];
        _charmImage.contentMode = UIViewContentModeScaleAspectFit;
        _charmImage.image = [UIImage imageNamed:@"grzx_account_diamond_icon"];
        [self.contentView addSubview:_charmImage];
        
        _timeLab = [[UILabel alloc] init];
        _timeLab.backgroundColor = [UIColor whiteColor];
        _timeLab.font = FontP(12);
        _timeLab.textColor = ColorI(0x2e353f);
        _timeLab.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_timeLab];
        
    }
    return self;
}

- (void)setModel:(CheekGiftModel *)model {
    _charmLabel.text = [NSString stringWithFormat:@"%@",model.charm];
    [_charmLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.top.equalTo(self.showImageView.mas_bottom).offset(10);
    }];
    
    [_charmImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.charmLabel.mas_right);
        make.top.equalTo(self.charmLabel.mas_top);
        make.height.with.mas_equalTo(_charmLabel.mas_width);
    }];
    
    _nameLabel.text = model.name;
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.top.equalTo(self.charmLabel.mas_bottom).offset(5);
    }];
    
    [_showImageView sd_setImageWithURL:[NSURL URLWithString:HttpImgUrl(model.img)] placeholderImage:[UIImage imageNamed:@"llustration"]] ;
    [_borderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_showImageView.mas_left).offset(-10);
        make.right.equalTo(_showImageView.mas_right).offset(10);
        make.top.equalTo(_showImageView.mas_top).offset(-10);
        make.bottom.equalTo(_showImageView.mas_bottom).offset(10);
    }];
    _timeLab.text = [NSString stringWithFormat:@"聊天时常增加%@S",model.time];
    [_timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.contentView);
        make.top.equalTo(_nameLabel.mas_bottom);
    }];
    
    
    
}

- (void)setIsSelect:(BOOL)isSelect {
    if (isSelect) {
        _borderImageView.hidden = NO;
    } else {
        _borderImageView.hidden = YES;
    }
}

@end
